import java.util.Scanner;
class ATM {
    public static void main(String[] args) {

        double banlance = 0;
        boolean flag = true;
        Scanner scn = new Scanner(System.in);

        while(flag){
            System.out.println("ATM");
            System.out.println(" 1、存款");
            System.out.println(" 2、取款");
            System.out.println(" 3、显示余额");
            System.out.println(" 4、退出");
            System.out.println("请选择(1-4)：");
            int res = scn.nextInt();//
            if(res == 1){
                System.out.println("请输入存款的金额");
                double price = scn.nextDouble();
                banlance = banlance + price;
            }else if(res == 2){
                System.out.println("请输入取款的金额");
                double price2 = scn.nextDouble();
                if(price2 > banlance){
                    System.out.println("金额不足");
                }else if(price2 <= 0){
                    System.out.println("输入金额有误");
                }else{
                    banlance = banlance - price2;
                }
            }else if(res == 3){

                System.out.println("金额为>" + banlance);
            }else if(res == 4){
                flag = false;

            }else{
                System.out.println("请选择正确的操作选项");
            }

        }













    }
}



